<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="申请单号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="申请日期" prop="FBILLCREDATE" disabled>
            <el-date-picker v-model="dataForm.FBILLCREDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="预约结果">
              <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
          <el-form-item label="预约人员" prop="FUSER" disabled>
            <el-input v-model="dataForm.FUSER"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="场地名称" prop="FCATNAME" disabled>
            <el-input v-model="dataForm.FCATNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="预约类别">
              <el-select v-model="dataForm.FBILLTYPE" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
          <el-form-item label="预约日期" prop="FUSEDATE" disabled>
            <el-date-picker v-model="dataForm.FUSEDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
        </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="开始时间" prop="FBEGTIME" >
            <el-input v-model="dataForm.FBEGTIME"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="结束时间" prop="FENDTIME" >
            <el-input v-model="dataForm.FENDTIME"   disabled/>
          </el-form-item>
        </el-col>

        <el-col :span="16">
          <el-form-item label="预约说明" prop="FMEMO" disabled>
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>

        <!-- <el-col :span="8">
          <el-form-item label="审核人员" prop="FCHECKUSE">
            <el-input v-model="dataForm.FCHECKUSE"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="审核说明" prop="FNOTE">
            <el-input v-model="dataForm.FNOTE"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="审核日期" prop="FCHECKDATE">
            <el-input v-model="dataForm.FCHECKDATE"  disabled />
          </el-form-item>
        </el-col> -->
        
        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加场地</el-button> -->
            <el-button type="primary" :loading="loading" @click="closePage">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <template>
     <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="预约工位" name="first">
        <el-table :data="list2" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNO" label="工位编号" ></el-table-column>
          <el-table-column prop="FWORKNAME" label="工位名称"></el-table-column>
          <el-table-column prop="FMEMO" label="备注信息" ></el-table-column>
       </el-table>
      </el-tab-pane>

      <el-tab-pane label="预约设备" name="second">
        <el-table :data="list" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FEQUIPNO" label="设备编号" ></el-table-column>
          <el-table-column prop="FEQUIPNAME" label="设备名称"></el-table-column>
       </el-table>
      </el-tab-pane>
      
      <el-tab-pane label="预约危化品" name="third">
        <el-table :data="list3" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNAME" label="危化品名称" ></el-table-column>
          <el-table-column prop="FCAS" label="CAS号"></el-table-column>
          <el-table-column prop="FQTY" label="用量" ></el-table-column>
          <el-table-column prop="FUNIT" label="单位" ></el-table-column>
          <el-table-column prop="FMEMO" label="备注" ></el-table-column>
       </el-table>
      </el-tab-pane>

      <el-tab-pane label="预约耗材" name="fourth">
        <el-table :data="list4" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNO" label="耗材编号"></el-table-column>
          <el-table-column prop="FWORKNAME" label="耗材名称" ></el-table-column>
          <el-table-column prop="FQTY" label="数量" ></el-table-column>
          <el-table-column prop="FUNIT" label="单位" ></el-table-column>
          <el-table-column prop="FMEMO" label="备注" ></el-table-column>
       </el-table>
      </el-tab-pane>

      <el-tab-pane label="人员列表" name="five">
        <el-table :data="list5" border stripe>
          <el-table-column label="操作" width="80">
            <template slot-scope="scope">
              <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
                type="text">删除</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
          <el-table-column prop="FWORKNO" label="人员编号"></el-table-column>
          <el-table-column prop="FWORKNAME" label="人员名称" ></el-table-column>
        </el-table>
        <div class="addbox">
             <el-link icon="el-icon-plus" type="primary" >添加一行</el-link>
        </div>
      </el-tab-pane>

    </el-tabs>
  </template>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        activeName: 'first',

        title: "新增",
        insertorupdate: true,
        dataForm: {
            FBILLNO: "K241130001", 
            FBILLCREDATE:"2024-11-29",
            FUSER: "曹操",
            FPARENTNO: "第一教学楼",
            FLAYNO:"一楼",
            FCATNAME: "101教室",
            FUSEDATE: "2024-12-01",
            FBEGTIME:"09:00",
            FENDTIME:"11:00",
            FMEMO: "有机化学实验操作课",
            FCHECKUSE: "",
            FCHECKDATE: "",
            FNOTE:"",
            FBILLTYPE:"教学申请",
            FBILLSTATE: "申请中"
        },
        rules: {
          FUSERNUMBER:[
            { required: true, message: '请输入学籍号码', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入申请人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入申请理由', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FEQUIPNO": "98001",
                  "FEQUIPNAME": "通风柜1-1"
                },
                { "FENTRYID":2,
                  "FEQUIPNO": "98002",
                  "FEQUIPNAME": "通风柜1-2"
                }],
        list2: [{  "FENTRYID":1,
                    "FWORKNO": "1-1",
                    "FWORKNAME": "1号工位",
                    "FMEMO": ""
                  },
                  { "FENTRYID":2,
                    "FWORKNO": "1-2",
                    "FWORKNAME": "2号工位",
                    "FMEMO": ""
                  }],
         list3: [{ "FENTRYID":1,
                  "FWORKNAME": "二乙基镁",
                  "FCAS": "557-18-6",
                  "FQTY":500,
                  "FUNIT":"ml",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FWORKNAME": "硫氰酸",
                  "FCAS": "463-56-9",
                  "FQTY":500,
                  "FUNIT":"ml",
                  "FMEMO": ""
                },
                { "FENTRYID":3,
                  "FWORKNAME": "甲酸乙烯酯",
                  "FCAS": "692-45-5",
                  "FQTY":500,
                  "FUNIT":"ml",
                  "FMEMO": ""
                }],

        list4: [{  "FENTRYID":1,
                    "FWORKNO": "200001",
                    "FWORKNAME": "医用口罩",
                    "FQTY":"5",
                    "FUNIT":"个",
                    "FMEMO": ""
                  },
                  { "FENTRYID":2,
                    "FWORKNO": "20002",
                    "FWORKNAME": "医用手套",
                    "FQTY":"5",
                    "FUNIT":"个",
                    "FMEMO": ""
                  }],
        list5: [{ "FENTRYID":1,
                  "FWORKNO": "700001",
                  "FWORKNAME": "李逵"
                },
                { "FENTRYID":2,
                  "FWORKNO": "700002",
                  "FWORKNAME": "柴荣"
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '1',
          label: '申请中'
        }, {
          value: '2',
          label: '已通过'
        }, {
          value: '3',
          label: '已驳回'
        }],

        //所属校区选择数据
        options2: [{
          value: '1',
          label: '教学申请'
        }, {
          value: '2',
          label: '培训人员'
        }, {
          value: '3',
          label: '外来人员'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      closePage(){
        console.log('关闭弹窗dialog');
        this.visible = false;
      },
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>